from flask import Flask

from app.models.base import db

# 创建app
def create_app():
    app = Flask(__name__)

    app.config.from_object("app.secure")

    app.config.from_object("app.setting")

    # print(app.config["HOST"])

    register_blueprint(app)

    db.init_app(app)
    db.create_all(app=app)

    return app

# 蓝图是不能替代app应用的，在蓝图中注册了视图函数后，还需要将蓝图插入app
def register_blueprint(app):
    from app.web import web
    app.register_blueprint(web)